package com.starmark.gateway.auth.provider.mapper;


import com.starmark.core.framework.base.SuperMapper;
import com.starmark.gateway.auth.provider.entity.GatewayAuthRrr;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author starmark
 * @since 2018-04-27
 */
@Mapper
public interface GatewayAuthRrrMapper extends SuperMapper<GatewayAuthRrr> {

    /**
     * 查找角色下的授权信息
     *
     * @param roleId 角色ID
     * @return 资源ID
     */
    @Select("select res_id from gateway_auth_rrr where role_id=#{roleId}")
    List<String> getRoleResource(@Param("roleId") String roleId);


    /**
     * 删除角色下的授权信息
     *
     * @param roleId 角色
     */
    @Delete("delete  from gateway_auth_rrr where role_id=#{roleId}")
    void deleteByRoleId(@Param("roleId") String roleId);


    /**
     * 删除角色下的授权信息
     *
     * @param roleId 角色ID
     */
    @Delete("delete  from gateway_auth_rrr where role_id=#{roleId} and res_id=#{resourceId}")
    void deleteByRoleIdAndResourceId(@Param("roleId") String roleId, @Param("resourceId") String resourceId);
}